package com.mUI;

import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import com.xike.kyt.R;

public class MyToast {

	public Toast toast;

	public void showToast(Context context, String text) {
		if (toast == null) {
			toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
		}
//		toast.cancel();
		WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, windowManager.getDefaultDisplay().getHeight() / 3);
		View view = View.inflate(context, R.layout.ui_mytoast, null);
		TextView tv = (TextView) view.findViewById(R.id.myToast_tv);
		tv.setText(text);
		tv.setGravity(Gravity.CENTER);
		toast.setDuration(Toast.LENGTH_SHORT);
		toast.setView(view);
		toast.show();
	}

}
